package com.lightsh.utility;

import org.jbox2d.common.Vec2;

import android.util.Log;

public class Tester {
	private static final String TAG = "Tester";
	
	
	/**
	 * 模拟一个圆的顺时针转一圈时的点
	 * @param originX
	 * @param originY
	 * @param radius
	 */
	public static final void testCircle(float originX, float originY, float radius){
		for(int i = (int) (originX + radius); i >= originX - radius; --i){
			for(int j = (int) originY; j <= originY + radius; ++j){
				double distance = GeometryUtility.getDistance(originX, originY, i, j);
				if(Math.abs(distance - radius) < 0.001){
					Log.w(TAG, "x = " + i + ", y = " + j + " : " + distance);
					
					float radian = GeometryUtility.getTargetRadian(originX, originY, i, j);
					
					Log.e(TAG, "radian = " + GeometryUtility.getTargetRadian(originX, originY, i, j) +  ", angle = " + GeometryUtility.getTargetAngle(originX, originY, i, j));
					
					// 根据计算出的弧度，计算出与原点距离为targetRadius的目标点x,y的值
					float targetRadius = 25;
					Vec2 targetPoint = GeometryUtility.getScalePoint(originX, originY, i, j, targetRadius);					
					Log.d(TAG, "x = " + targetPoint.x + ", y = " + targetPoint.y + " : " + targetRadius);
					
					Vec2 targetRadianPoint = GeometryUtility.getTargetRadianPoint(originX, originY, radian, targetRadius);
					Log.e(TAG, "x = " + targetRadianPoint.x + ", y = " + targetRadianPoint.y + " : " + targetRadius);
					
					Log.i(TAG, "---------------------");
					
				}
			}
		}
		
		for(int i = (int) (originX - radius); i <= originX + radius; ++i){
			for(int j = (int) (originY - radius); j <= originY; ++j){
				double distance = GeometryUtility.getDistance(originX, originY, i, j);
				if(Math.abs(distance - radius) < 0.001){
					Log.w(TAG, "x = " + i + ", y = " + j + " : " + distance);
					
					float radian = GeometryUtility.getTargetRadian(originX, originY, i, j);
					
					Log.e(TAG, "radian = " + GeometryUtility.getTargetRadian(originX, originY, i, j) +  ", angle = " + GeometryUtility.getTargetAngle(originX, originY, i, j));
					
					// 根据计算出的弧度，计算出与原点距离为targetRadius的目标点x,y的值
					float targetRadius = 25;
					Vec2 targetPoint = GeometryUtility.getScalePoint(originX, originY, i, j, targetRadius);					
					Log.d(TAG, "x = " + targetPoint.x + ", y = " + targetPoint.y + " : " + targetRadius);
					
					Vec2 targetRadianPoint = GeometryUtility.getTargetRadianPoint(originX, originY, radian, targetRadius);
					Log.e(TAG, "x = " + targetRadianPoint.x + ", y = " + targetRadianPoint.y + " : " + targetRadius);
					
					Log.i(TAG, "---------------------");
				}
			}
		}
	}
}
